//
//  BookDetailsViewController.m
//  shike
//
//  Created by RegentSoft on 2017/4/20.
//  Copyright © 2017年 RegentSoft. All rights reserved.
//

#import "BookDetailsViewController.h"
#import "BookDetailsTableViewCell.h"
#import "HyperlinksController.h"
@interface BookDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>{
    
}
@property(nonatomic,strong)UITableView *foundTabView;
@property(nonatomic,strong)NSMutableArray *modelArray;
@end
@implementation BookDetailsViewController
-(void)viewWillAppear:(BOOL)animated{
    _modelArray = [[NSMutableArray alloc] init];
    [self httpRequest];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //导航栏的标题颜色字体
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"#999999"];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor colorWithHexString:@"#323232"],NSFontAttributeName :[UIFont systemFontOfSize:16.0]}];
    self.title = @"书本详情";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F0F0F5"];
    _foundTabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    _foundTabView.delegate = self;
    _foundTabView.dataSource = self;
    [self.view addSubview:_foundTabView];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, 50)];
    bgView.backgroundColor = [UIColor colorWithHexString:mainBgColor];
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 10, DeviceWidth, 40)];
    view.backgroundColor = [UIColor whiteColor];
    [bgView addSubview:view];
    UILabel * titleLabel =[[UILabel alloc] initWithFrame:CGRectMake(15, 10, 160, 20)];
    titleLabel.text = @"模块";
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.textColor = [UIColor colorWithHexString:@"#323232"];
    titleLabel.font = [UIFont systemFontOfSize:14.0];
    [view addSubview:titleLabel];
    return bgView;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }else{
        return 5;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 30;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * cellIdenifer =@"cellIdenifer";
    BookDetailsTableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:cellIdenifer];
    if (!cell) {
        cell =[[BookDetailsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdenifer];
    }
    if (_modelArray.count>0) {
    }
    cell.titleLabel.text = @"1-1销售技巧培训";
    cell.contentLabel.text = @"d8dd8";
    cell.contentLabel.text = @"图文";
    cell.contentLabel.layer.cornerRadius = 10.0;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    HyperlinksController * hyperView = [[HyperlinksController alloc] init];
    hyperView.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:hyperView animated:YES];
}
-(void)httpRequest{
//    [self loadProgressViewIsShow:YES];
//    NSString * urlString =@"http://120.77.252.204/api/module/list?tenantId=d8dd8152143711e7a393a45e60ce3abd&status=1";
//    [[RSNetworkManager sharedManager] GET:urlString parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
//        NSLog(@"1111====%@",dic);
//        NSDictionary * dataDic = [dic objectForKey:@"data"];
//        if ([dataDic allKeys].count>0) {
//            _modelArray = [dataDic objectForKey:@"module_list"];
//            [_foundTabView reloadData];
//        }
//        [self loadProgressViewIsShow:NO];
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        [self loadProgressViewIsShow:NO];
//        [self showLoadProgressViewWithMessage:error.localizedDescription delay:2.0];
//    }];
}

@end
